package com.hup.minicontroller.client.view.main;

import com.hup.utils.swing.customView.BaseUndoText;
import com.hup.utils.swing.customView.HScrollPanel;
import com.hup.utils.swing.customView.HintTextField;
import com.hup.utils.swing.customView.ViewText;

import javax.swing.*;
import javax.swing.undo.UndoManager;
import java.awt.*;

/**
 * 服务端连接列表面板
 *
 * @author hugan
 * @date 2021/5/23
 */
public class MainForm extends JPanel {

    public JPanel root;
    //
    public HintTextField txtToConnect;
    public JButton btnConnectLan;
    public ViewText txtHotspotGateway;
    public JButton btnConnectHotspot;
    //
    public JPanel pScannedServer;

    public MainForm() {
        super(new BorderLayout());
        $$$setupUI$$$();
        BaseUndoText.initUndo(txtToConnect, new UndoManager());
    }

    /**
     * Method generated by IntelliJ IDEA GUI Designer
     * >>> IMPORTANT!! <<<
     * DO NOT edit this method OR call it in your code!
     *
     * @noinspection ALL
     */
    private void $$$setupUI$$$() {
        createUIComponents();
        root.setLayout(new GridBagLayout());
        root.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8), null));
        final JPanel panel1 = new JPanel();
        panel1.setLayout(new GridBagLayout());
        GridBagConstraints gbc;
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        root.add(panel1, gbc);
        final JLabel label1 = new JLabel();
        label1.setText("局域网服务端");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(0, 0, 0, 8);
        panel1.add(label1, gbc);
        final JLabel label2 = new JLabel();
        label2.setText("热点服务端");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.anchor = GridBagConstraints.WEST;
        panel1.add(label2, gbc);
        txtToConnect = new HintTextField();
        txtToConnect.setText("192.168.1.100");
        txtToConnect.setToolTipText("ip地址");
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 0;
        gbc.gridwidth = 2;
        gbc.weightx = 1.0;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(0, 0, 0, 8);
        panel1.add(txtToConnect, gbc);
        btnConnectLan = new JButton();
        btnConnectLan.setText("连接");
        gbc = new GridBagConstraints();
        gbc.gridx = 3;
        gbc.gridy = 0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        panel1.add(btnConnectLan, gbc);
        btnConnectHotspot = new JButton();
        btnConnectHotspot.setText("尝试连接");
        gbc = new GridBagConstraints();
        gbc.gridx = 3;
        gbc.gridy = 1;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        panel1.add(btnConnectHotspot, gbc);
        txtHotspotGateway = new ViewText();
        txtHotspotGateway.setText("192.168.1.1");
        txtHotspotGateway.setToolTipText("不一定准确的!");
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 1;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        panel1.add(txtHotspotGateway, gbc);
        final JLabel label3 = new JLabel();
        label3.setText("(点击刷新)");
        gbc = new GridBagConstraints();
        gbc.gridx = 2;
        gbc.gridy = 1;
        gbc.anchor = GridBagConstraints.WEST;
        panel1.add(label3, gbc);
        final HScrollPanel hScrollPanel1 = new HScrollPanel();
        hScrollPanel1.setHorizontalScrollBarPolicy(31);
        hScrollPanel1.setVerticalScrollBarPolicy(20);
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        root.add(hScrollPanel1, gbc);
        final JPanel panel2 = new JPanel();
        panel2.setLayout(new GridBagLayout());
        hScrollPanel1.setViewportView(panel2);
        pScannedServer = new JPanel();
        pScannedServer.setLayout(new GridBagLayout());
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        panel2.add(pScannedServer, gbc);
        final JPanel spacer1 = new JPanel();
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.VERTICAL;
        panel2.add(spacer1, gbc);
    }

    /**
     * @noinspection ALL
     */
    public JComponent $$$getRootComponent$$$() { return root; }

    private void createUIComponents() {
        root = this;
        pScannedServer = new JPanel(new GridLayout(0, 1));
    }
}
